<template>
	<view>
		<uni-nav-bar :statusBar="true" rightText="发布" @click-right="submit" left-icon="back" @click-left="back"  :border="false">
			<view class="u-f-ajc" style="width: 100%;" @tap="changeLook">
				{{itemList[index]}}
				<view class="icon iconfont icon-xialazhankai">
				</view>
			</view>
		</uni-nav-bar>
		<!-- 多行输入框 -->
		<view class="uni-textarea">
			<textarea v-model="text" placeholder="说一句话吧～" />
			</view>
		<!-- 上传多图 -->
		<upload-images @upload="uploadImages"></upload-images>
		<!-- 弹出公告 -->
		<uni-popup :show="showpopup" type="center">
			 <view class="gonggao">
				 <view class="u-f-ajc">
				 	<image src="../../static/common/addinput.png" mode="widthFix"></image>
				 </view>
				 <view>1. 涉及黄色，政治，广告及骚扰信息 </view>
				 <view>2. 涉及黄色，政治，广告及骚扰信息 </view>
				 <view>3. 涉及黄色，政治，广告及骚扰信息 </view>
				 <view>4. 涉及黄色，政治，广告及骚扰信息 </view>
				 <button type="primary" @tap="hidePopup">朕知道了～</button>
			 </view>
		</uni-popup>
	</view>
</template>

<script>
	import uniNavBar from "../../components/uni-nav-bar/uni-nav-bar.vue";
	import uploadImages from "../../components/common/upload-images.vue"
	import uniPopup from "../../components/uni-popup/uni-popup.vue";

	export default {
		components: {
			uniNavBar,
			uploadImages,
			uniPopup
		},
		data() {
			return {
				isget:false,
				showpopup: true,
				itemList: ["所有人可见","仅自己可见"],
				index:0,
				text:"",
				imageList:[]
			}
		},
		onLoad() {
			// this.showpopup = true;
		},
		onBackPress() {
			if ((this.imageList.length != 0 || this.text.length != 0) && !this.isget) {
				console.log("isget:",this.isget);
				uni.showModal({
					content:"是否保存为草稿",
					cancelText:"不保存",
					confirmText:"保存",
					success: (res) => {
						if (res.confirm) {
							console.log("保存");
						} else {
							console.log("不保存");
						}
						this.isget = true;
						uni.navigateBack({});
					}
				});
				return true;
			}
		},
		methods: {
			back() {
				uni.navigateBack({});
			},
			submit(){
				console.log("发布");
			},
			changeLook(){
				console.log("changeLook");
				uni.showActionSheet({
					itemList: this.itemList,
					success: res => {
						// console.log(res.tapIndex);
						this.index = res.tapIndex;
					},
					fail: () => {},
					complete: () => {}
				});
			},
			uploadImages(imageList){
				this.imageList = imageList;
				console.log(this.imageList);
			},
			hidePopup(){
				this.showpopup = false;
				
			}
		}
	}
</script>

<style scoped>
	.uni-textarea{
		border: 1upx solid #EEEEEE;
	}

	.gonggao{
		background-color: #FFFFFF;
		padding: 20upx;
		border-radius: 10upx;
		width: 500upx;
	}
	
	.gonggao image {
		width: 85%;
		margin-bottom: 20upx;
	}
	
	.gonggao button {
		margin-top: 20upx;
		background-color: #FFE934;
		color: #171606;
	}
</style>
